package com.ruoyi.logistic.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.*;
import com.ruoyi.logistic.domain.vo.NetworkClientGoAreaIncomeVo;
import com.ruoyi.logistic.domain.vo.NetworkOutboundGoAreaIncomeVo;
import com.ruoyi.logistic.domain.vo.NetworkUndertakeGoAreaIncomeVo;
import com.ruoyi.logistic.service.NetworkAreaIncomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/network/areaIncome")
@RestController
@Api(tags = "网点财务_区域收入分析")
public class NetworkAreaIncomeController {
    @Autowired
    private NetworkAreaIncomeService networkAreaIncomeService;

    @ApiOperation("出港")
    @PostMapping("/outbound")
    public R outboundGoAreaIncome(@RequestBody NetworkOutboundGoAreaIncomeVo vo){
        if (vo.getStartTime() == null || vo.getEndTime() == null || vo.getNetworkNameId() == null){
            return R.fail("请选择所需的时间参数和网点信息");
        }
        if (vo.getProvince() == null){
            return R.fail("请传入省份信息");
        }
        List<NetworkOutboundGoAreaIncome> outboundGoAreaIncomes = networkAreaIncomeService.outboundGoAreaIncome(vo);
        if (outboundGoAreaIncomes == null || outboundGoAreaIncomes.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(outboundGoAreaIncomes));
        }
    }

    @ApiOperation("承包区")
    @PostMapping("/undertake")
    public R undertakeGoAreaIncome(@RequestBody NetworkUndertakeGoAreaIncomeVo vo){
        if (vo.getStartTime() == null || vo.getEndTime() == null || vo.getNetworkNameId() == null){
            return R.fail("请选择所需的时间参数和网点信息");
        }
        if (vo.getProvince() == null){
            return R.fail("请传入省份信息");
        }
        List<NetworkUndertakeGoAreaIncome> undertakeGoAreaIncomes = networkAreaIncomeService.undertakeGoAreaIncome(vo);
        if (undertakeGoAreaIncomes == null || undertakeGoAreaIncomes.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(undertakeGoAreaIncomes));
        }
    }

    @ApiOperation("客户")
    @PostMapping("/client")
    public R clientGoAreaIncome(@RequestBody NetworkClientGoAreaIncomeVo vo){
        List<NetworkClientGoAreaIncome> clientGoAreaIncomes = networkAreaIncomeService.clientGoAreaIncome(vo);
        if (clientGoAreaIncomes == null || clientGoAreaIncomes.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(clientGoAreaIncomes));
        }
    }
}
